package com.honglang.module.user.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;


import com.honglang.dao.GenericDaoImpl;
import com.honglang.module.user.entity.User;

public class UserDaoImpl extends GenericDaoImpl<User,Integer> implements UserDao{
	
	/**
	 *  Get user list by userName;
	 * @param userName
	 * @return
	 */
	public List<User> getUserByUsername(String userName){
		
		DetachedCriteria dc = DetachedCriteria.forClass(User.class);
		dc.add(Restrictions.eq("userName", userName));
		
		return this.getByDetachedCriteria(dc);
	}
	
	
	/**
	 *  Get user list by email;
	 * @param userName
	 * @return
	 */
	public List<User> getUserByEmail(String email){
		DetachedCriteria dc = DetachedCriteria.forClass(User.class);
		dc.add(Restrictions.eq("email", email));
		
		return this.getByDetachedCriteria(dc);
	}
	
	
	
	
}
